package company.guanglianda;

import java.math.BigDecimal;
import java.util.*;

public class GuangLianDa1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long result = -1;
        Map<Integer, Integer> dict = new TreeMap<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        int num;
        for (int i = 0; i < n; i++) {
            num = sc.nextInt();
            dict.put(num, dict.getOrDefault(num, 0) + 1);
        }
        if (n == 1) {
            System.out.println(-1);
            return;
        }
        for (Map.Entry<Integer, Integer> e : dict.entrySet()) {
            if (e.getValue() >= 2) {
                if (result == -1)
                    result = e.getKey();
                else {
                    BigDecimal b1 = new BigDecimal(String.valueOf(result));
                    BigDecimal b2 = new BigDecimal(String.valueOf(e.getKey()));
                    System.out.println(b1.multiply(b2).toString());
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}
